import { _decorator, Component, director, instantiate, Node, Prefab, Sprite, SpriteFrame, tween, v3, Vec3 } from 'cc';
import { FishMgr } from './FishMgr';
import { FishEvent } from '../Enums';
import { CannonControl } from './CannonControl';
import { Global } from '../Global';
import { gameMgr } from '../../gameMgr';
const { ccclass, property } = _decorator;

@ccclass('BulletLine')
export class BulletLine extends Component {
    
    img:Sprite = null;
    


    onLoad() {
        this.img = this.node.getChildByName("img").getComponent(Sprite);
    }

    start() {

    }

    setBullet(sprf_num:number){
        this.img.spriteFrame = Global.zdImgs[sprf_num];

    }

    onFireMove(pos :Vec3){
        console.log("子弹移动动画")

        let bullet_line = this.node;
        //同时执行移动缩放
        let anim1 = tween(bullet_line).to(0.25, { position: pos }, { easing: 'quadIn' })
        let anim2 = tween(bullet_line).to(0.1, { scale: Vec3.ONE }, { easing: 'quadIn' })
        tween(bullet_line).parallel(anim2, anim1)
            .call(() => {
                //const _pos = bullet_line.getPosition()
                // CannonControl.Inst.onOpenNet(_pos , fish_near);
                
                bullet_line.removeFromParent();
            }).start();
        
        
    }

}


